home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / FixMath.p < prev    next >
Encoding:
Text File  |  1998-02-12  |  5.2 KB  |  181 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        FixMath.p
  3.  
  4.      Contains:    Fixed Math Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8
  7.                  Release:    Universal Interfaces 3.1
  8.  
  9.      Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT FixMath;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __FIXMATH__}
  28. {$SETC __FIXMATH__ := 1}
  29.  
  30. {$I+}
  31. {$SETC FixMathIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __MACTYPES__}
  35. {$I MacTypes.p}
  36. {$ENDC}
  37.  
  38.  
  39. {$PUSH}
  40. {$ALIGN MAC68K}
  41. {$LibExport+}
  42.  
  43.  
  44.  
  45.  
  46. CONST
  47.     fixed1                        = $00010000;
  48.     fract1                        = $40000000;
  49.     positiveInfinity            = $7FFFFFFF;
  50.     negativeInfinity            = $80000000;
  51.  
  52. {
  53.     Previously in ToolUtils.i.  Moved here because it makes more sense.
  54. }
  55. {$IFC NOT OLDROUTINELOCATIONS }
  56. FUNCTION FixRatio(numer: INTEGER; denom: INTEGER): Fixed;
  57.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  58.     INLINE $A869;
  59.     {$ENDC}
  60. FUNCTION FixMul(a: Fixed; b: Fixed): Fixed;
  61.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  62.     INLINE $A868;
  63.     {$ENDC}
  64. FUNCTION FixRound(x: Fixed): INTEGER;
  65.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  66.     INLINE $A86C;
  67.     {$ENDC}
  68. {$ENDC}
  69.  
  70. FUNCTION Fix2Frac(x: Fixed): Fract;
  71.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  72.     INLINE $A841;
  73.     {$ENDC}
  74. FUNCTION Fix2Long(x: Fixed): LONGINT;
  75.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  76.     INLINE $A840;
  77.     {$ENDC}
  78. FUNCTION Long2Fix(x: LONGINT): Fixed;
  79.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  80.     INLINE $A83F;
  81.     {$ENDC}
  82. FUNCTION Frac2Fix(x: Fract): Fixed;
  83.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  84.     INLINE $A842;
  85.     {$ENDC}
  86. FUNCTION FracMul(x: Fract; y: Fract): Fract;
  87.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  88.     INLINE $A84A;
  89.     {$ENDC}
  90. FUNCTION FixDiv(x: Fixed; y: Fixed): Fixed;
  91.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  92.     INLINE $A84D;
  93.     {$ENDC}
  94. FUNCTION FracDiv(x: Fract; y: Fract): Fract;
  95.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  96.     INLINE $A84B;
  97.     {$ENDC}
  98. FUNCTION FracSqrt(x: Fract): Fract;
  99.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  100.     INLINE $A849;
  101.     {$ENDC}
  102. FUNCTION FracSin(x: Fixed): Fract;
  103.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  104.     INLINE $A848;
  105.     {$ENDC}
  106. FUNCTION FracCos(x: Fixed): Fract;
  107.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  108.     INLINE $A847;
  109.     {$ENDC}
  110. FUNCTION FixATan2(x: LONGINT; y: LONGINT): Fixed;
  111.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  112.     INLINE $A818;
  113.     {$ENDC}
  114. {
  115.     Frac2X, Fix2X, X2Fix, and X2Frac translate to and from
  116.     the floating point type "extended" (that's what the X is for).
  117.     On the original Mac this was 80-bits and the functions could be
  118.     accessed via A-Traps.  When the 68881 co-processor was added,
  119.     it used 96-bit floating point types, so the A-Traps could not 
  120.     be used.  When PowerPC was added, it used 64-bit floating point
  121.     types, so yet another prototype was added.
  122. }
  123. {$IFC TARGET_CPU_68K }
  124. {$IFC TARGET_RT_MAC_68881 }
  125. FUNCTION Frac2X(x: Fract): extended;
  126. FUNCTION Fix2X(x: Fixed): extended;
  127. FUNCTION X2Fix(x: extended): Fixed;
  128. FUNCTION X2Frac(x: extended): Fract;
  129. {$ELSEC}
  130. FUNCTION Frac2X(x: Fract): extended;
  131.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  132.     INLINE $A845;
  133.     {$ENDC}
  134. FUNCTION Fix2X(x: Fixed): extended;
  135.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  136.     INLINE $A843;
  137.     {$ENDC}
  138. FUNCTION X2Fix(x: extended): Fixed;
  139.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  140.     INLINE $A844;
  141.     {$ENDC}
  142. FUNCTION X2Frac(x: extended): Fract;
  143.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  144.     INLINE $A846;
  145.     {$ENDC}
  146. {$ENDC}
  147. {$ELSEC}
  148. FUNCTION Frac2X(x: Fract): Double;
  149. FUNCTION Fix2X(x: Fixed): Double;
  150. FUNCTION X2Fix(x: Double): Fixed;
  151. FUNCTION X2Frac(x: Double): Fract;
  152. {$ENDC}  {TARGET_CPU_68K}
  153.  
  154. {  QuickTime 3.0 makes these Wide routines available on other platforms }
  155. {$IFC TARGET_CPU_PPC OR NOT TARGET_OS_MAC }
  156. FUNCTION WideCompare({CONST}VAR target: wide; {CONST}VAR source: wide): INTEGER; C;
  157. FUNCTION WideAdd(VAR target: wide; {CONST}VAR source: wide): WidePtr; C;
  158. FUNCTION WideSubtract(VAR target: wide; {CONST}VAR source: wide): WidePtr; C;
  159. FUNCTION WideNegate(VAR target: wide): WidePtr; C;
  160. FUNCTION WideShift(VAR target: wide; shift: LONGINT): WidePtr; C;
  161. FUNCTION WideSquareRoot({CONST}VAR source: wide): UInt32; C;
  162. FUNCTION WideMultiply(multiplicand: LONGINT; multiplier: LONGINT; VAR target: wide): WidePtr; C;
  163. { returns the quotient }
  164. FUNCTION WideDivide({CONST}VAR dividend: wide; divisor: LONGINT; VAR remainder: LONGINT): LONGINT; C;
  165. { quotient replaces dividend }
  166. FUNCTION WideWideDivide(VAR dividend: wide; divisor: LONGINT; VAR remainder: LONGINT): WidePtr; C;
  167. FUNCTION WideBitShift(VAR src: wide; shift: LONGINT): WidePtr; C;
  168. {$ENDC}
  169.  
  170.  
  171. {$ALIGN RESET}
  172. {$POP}
  173.  
  174. {$SETC UsingIncludes := FixMathIncludes}
  175.  
  176. {$ENDC} {__FIXMATH__}
  177.  
  178. {$IFC NOT UsingIncludes}
  179.  END.
  180. {$ENDC}
  181.